<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMembersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('members', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->char('openid', 64)->default('')->comment('微信公众平台openid');
            $table->string('name', 255)->default('');
            $table->string('nickname', 255)->default('');
            $table->string('email', 255)->default('');
            $table->string('avatar', 255)->default('');
            $table->tinyInteger('sex')->default('0');
            $table->char('language', 32)->default('');
            $table->string('city', 255)->default('');
            $table->string('province', 255)->default('');
            $table->string('country', 255)->default('');
            $table->string('access_token', 255)->default('');
            $table->string('refresh_token', 255)->default('');
            $table->dateTime('expires_time')->nullable();
            $table->dateTime('created_at')->nullable();
            $table->dateTime('updated_at')->nullable();
            $table->dateTime('deleted_at')->nullable();
            $table->index(['openid']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (Schema::hasTable('members')) {
            Schema::drop('members');
        }
    }
}
